* This file provides the code for the numerical results and Figures 2-4
*	presented in the main text

******************************************************
****************** MAIN MODELS ***********************
******************************************************

cd "/Users/jrthornton/Desktop/POBE 2021 replication"	
log using "Main Results" , text replace

set more off

* Table 1
* Analysis of equality and sophisiticaion 
use "/Users/jrthornton/Desktop/POBE 2021 replication/Data/Cumulative file coded.dta" , replace
reg equality_irt c.soph_irt pidi i.sex income age educ i.race ideology  if year>2005 & pid<4
	margins , at(soph_irt=(0(1)1))
*Bivaraite analysis:
	corr equality_irt

*Table 2
* Aid to blacks:			  
use "/Users/jrthornton/Desktop/POBE 2021 replication/Data/Cumulative file coded.dta" , replace
reg black_issues_irt ib1.race##c.soph_irt pidi age income educ sex equality_irt ideology if year>2005 & pid<4 
	margins , at(soph_irt=(0(1)1)) over(race)
*Welfare and aid to poor:
use "/Users/jrthornton/Desktop/POBE 2021 replication/Data/Cumulative file coded.dta" , replace
reg welfare_support_irt c.income##c.soph_irt pidi age  educ i.race sex equality_irt ideology if year>2005 & pid<4
	margins , at(soph_irt=(0(1)1) income=(1(1)5)) 
	
* Gay and lesbian policies 
use "/Users/jrthornton/Desktop/POBE 2021 replication/Data/gay_rights.dta"
reg gay_irt c.soph_irt i.race income equality_irt pidi ideo age educ sex if party==0 & gay==0
	margins , at(soph_irt=(0(.1)1))

**************************************************
****************** Figures ***********************
**************************************************

* Note: The R script "4. Figures 1 and 5.R" creates figures 1 and 5

* Figure 2
* Relationship between sopistication and aid to blacks conditioned on race
use "/Users/jrthornton/Desktop/POBE 2021 replication/Data/fig2.dta"
# delimit ;
twoway
(rarea upper lower soph if race==1, lcolor(maroon%25)  fcolor(maroon%25))
(rarea upper lower soph if race==2, lcolor(sea%25) fcolor(sea%25))
(rarea upper lower soph if race==3, lcolor(orangebrown%25) fcolor(orangebrown%25))
(line y soph if race==1, lcolor(maroon) lpattern(solid))
(line  y soph if race==2, lcolor(sea) lpattern(shortdash))
(line  y soph if race==3, lcolor(orangebrown) lpattern(longdash_dot))
( scatteri .635 .125 "Black"
,   msymbol(i) mlabpos(0)    
	mlabangle(352.5) 
	mlabs(medium)
)
( scatteri .3425 .125 "White"
,   msymbol(i) mlabpos(0)    
   mlabangle(30) 
   mlabs(medium)
)
( scatteri .4375 .125 "Latinx"
,   msymbol(i) mlabpos(0)    
   mlabangle(10) 
   mlabs(medium)
)
,
aspect(1)
ylab(, format(%03.1f))
xlab(, format(%03.1f))
ytitle("Scale: support for affirmative action" "and aid to blacks")
xtitle(Sophistication) legend(off)
plotregion(margin(zero))
;
# delimit cr




* Figure 3
* Relationship between sopistication and aid to poor conditioned on income
use "/Users/jrthornton/Desktop/POBE 2021 replication/Data/fig3.dta"
# delimit ;
	twoway
	(rarea lower upper soph if income==1, lcolor(sea%25)  fcolor(sea%25))
	(rarea  lower upper soph if income==3, lcolor(orangebrown%25) fcolor(orangebrown%25))
	(rarea  lower upper soph if income==5, lcolor(maroon%25) fcolor(maroon%25))
	(line y soph if income==1, lcolor(sea) lpattern(shortdash))
	(line y soph if income==3, lcolor(orangebrown) lpattern(longdash_dot))
	(line y soph if income==5, lcolor(maroon))
	( scatteri .5375 .14 "High"
		,   msymbol(i) mlabpos(0)    
       mlabangle(30) 
       mlabs(medium)
	)
	( scatteri .66 .1 "Middle"
		,
		msymbol(i) mlabpos(0)    
		mlabangle(8.5) 
		mlabs(medium)
	)
	( scatteri .7825 .2 "Low income"
	,   msymbol(i) mlabpos(0)    
		mlabangle(344) 
		mlabs(medium)
	)
,
aspect(1)
ylab(, format(%03.1f))
xlab(0(.2).8 .999 "1.0", format(%03.1f))
	ytitle("Scale: Support for welfare and aid to poor")
	xtitle(Sophistication) legend(off)
plotregion(margin(zero))
;
# delimit cr



* Relationship between sopistication and LGBTQ policies for starights
use "/Users/jrthornton/Desktop/POBE 2021 replication/Data/fig4.dta"
# delimit ;
twoway
	(rarea upper lower soph , lcolor(gs8) fcolor(gs12))
	(line y soph, lcolor(black) lpattern(solid))
	(function y = .93 , lcolor(none))
	,	 
	ylab(.6(.1).9, format(%03.1f))
	xlab(, format(%03.1f))
	ytitle("Scale: Support for gay and lesbian rights")
	xtitle(Sophistication) 
	aspect(1)
	plotregion(margin(zero))
    legend(off)
	yline(.92)
	;
*# delimit cr


log close
